<!DOCTYPE html>
<html lang="zh">
<head>
    <title>关于</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/css/layui.css">
    <script src="/static/js/layui.js"></script>
    <script src="/static/js/jquery-3.5.1.min.js"></script>
    <style>
        body {
            background-color: #f2f1f1;
            background-repeat:no-repeat;
            background-attachment:fixed

        }
        .global-body {
            width: 100%;
            margin: 2% 4%;
        }
    </style>
</head>
{{template "header" .}}
<body>
<div class="global-body">
    <div style="width: 90%;margin-left: 4%">
        <hr class="layui-bg-black">
        <button id="import" style="width: 120px;min-height: 30px" type="button" class="layui-input-inline layui-btn layui-btn-primary ">导入</button>
        <a download href="/tools/export">
            <button id="export" style="margin-left: 20px;width: 120px;min-height: 30px" type="button" class="layui-input-inline layui-btn layui-btn-primary ">导出</button>
        </a>
        <hr class="layui-bg-black">
    </div>

    <div class="layui-input-inline" style="width: 42%;display: none">
        <input onchange="uploadFile()" id="selectFile" type='file' name="files" style="min-height: 30px;width: 230px;align-items: center;">
    </div>


    <script>
        $("#import").click(function () {
            $("#selectFile").click()
        })
        function uploadFile() {
            var dataFile = $("#selectFile")[0].files[0];
            var formData = new FormData()
            formData.append("dataFile", dataFile)
            $.ajax({
                "url" : "/tools/import",
                "type" : "post",
                "data" : formData,
                "success" : callBack,
                "contentType": false,
                "processData": false,
                "error" : function(err) {
                    console.log(err)
                }
            });
            function callBack(data) {
                if (data.code !== "400") {
                    layer.msg(data.msg)
                }else {
                    layer.msg(data.msg)
                }
                $("#selectFile").val(null)
            }
        }
    </script>
</div>
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;
    });
    //From
    layui.use('form', function(){
        var form = layui.form;
    });
</script>
</body>
</html>
